﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LINQtoNHibernateMVC.Core.Domain.Model {
	public abstract class Entity : IEquatable<Entity> {
		public virtual Guid Id { get; protected set; }

		public virtual bool Equals(Entity other) {
			if (ReferenceEquals(null, other)) return false;
			if (ReferenceEquals(this, other)) return true;
			if (GetType() != other.GetType()) return false;
			return other.Id == Id;
		}
		public override bool Equals(object obj) {
			return Equals(obj as Entity);
		}
		public override int GetHashCode() {
			return (GetType().FullName + Id).GetHashCode();
		}
		public static bool operator ==(Entity left, Entity right) {
			return Equals(left, right);
		}
		public static bool operator !=(Entity left, Entity right) {
			return !Equals(left, right);
		}
	}
}
